package com.wlyuan.open.domain.source.utils;

import com.wlyuan.open.domain.source.SourceClass;
import com.wlyuan.open.domain.source.SourceDataId;
import com.wlyuan.open.domain.source.SourceStatus;
import com.wlyuan.open.domain.source.constants.AutoBalanceEnum;

import java.util.Optional;

/**
 * @author yuanzheng
 */
public class MappingSource {
    public SourceDataId createSourceRawId(Long value) {
        return Optional.ofNullable(value)
                .map(SourceDataId::new)
                .orElse(null);
    }

    public SourceStatus createSourceStatus(Integer value) {
        return SourceStatus.fromValue(value);
    }

    public SourceClass createSourceClass(Integer value) {
        return SourceClass.fromValue(value);
    }

    public Boolean autoBalance(Integer val) {
        return AutoBalanceEnum.fromValue(val).getNewValue();
    }
}
